
#include<stdio.h>
#define MAX 10000000000000000

typedef unsigned long long ull;

ull n,k,M;
int D;

int min(ull a,int b)
{
	return a<b?a:b;
}

ull max(ull a,ull b)
{
	return a>b?a:b;
}

int main()
{
	scanf("%llu%llu%llu%d",&n,&k,&M,&D);
	ull m;
	ull res=0;
	if(n<k*M)
	{
		res=M;
	}
	else
	{
		if(D==1)
		{
			res=M;
		}
		else
		{
			for(int i=D;i>1;i--)
			{
				
				if(n/((i-1)*k+1)<=M&&n/((i-1)*k+1)>0&&(ull)(((i-1)/100)*k+1)<MAX)
				{
					m=n/((i-1)*k+1);
					if(m<n/((i-1)*k+k-1))
					{
						int a=1;
						while(m<=n/((i-1)*k+a+1)&&m)
						{
							if(m<n/((i-1)*k+a+1)&&m)
							{
								m=n/((i-1)*k+a+1);
								break;
							}
							a++;
							//printf("-------------%d\n",a);
						}
					}	
					res=max(m*i,res);
				}
				else if((n/((i-1)*k+1)-M)*(n/((i-1)*k+1))<M*k&&n/((i-1)*k+1)>0&&(ull)(((i-1)/100)*k+1)<MAX)
				{
					res=max(M*i,res);
				}
				//printf("-------------%d\n",res);
			}
		}
	}
	printf("%llu\n",res);
	return 0;
} 


/*
#include<stdio.h>

typedef unsigned long long ull;

double n,k,M;
int D;

int min(double a,int b)
{
	return a<b?a:b;
}

double max(double a,double b)
{
	return a>b?a:b;
}

int main()
{
	scanf("%lf%lf%lf%d",&n,&k,&M,&D);
	double m;
	double res=0;
	if(n<k*M)
	{
		res=M;
	}
	else
	{
		if(D==1)
		{
			res=M;
		}
		else
		{
			for(int i=11;i>1;i--)
			{
				
				if((int)(n/((i-1)*k+1))<=M&&n/((i-1)*k+1)>=1)
				{
					m=(int)(n/((i-1)*k+1));
					if(m<(int)(n/((i-1)*k+k-1)))
					{
						int a=1;
						while(m<=(int)(n/((i-1)*k+a+1))&&m)
						{
							if(m<(int)(n/((i-1)*k+a+1))&&m)
							{
								m=(int)(n/((i-1)*k+a+1));
								break;
							}
							a++;
							//printf("-------------%d\n",a);
						}
					}	
					res=max(m*i,res);
				}
				else if((int)((n/((i-1)*k+1)-M)*(n/((i-1)*k+1)))<M*k&&n/((i-1)*k+1)>=1)
				{
					res=max(M*i,res);
				}
				//printf("-------------%d\n",res);
			}
		}
	}
	printf("%.0lf\n",res);
	return 0;
} 
*/
